﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace GDFlacTool.Forms
{
    public partial class FormSplash : Form
    {
        private static Thread _splashThread;
        private static FormSplash _splashForm;


        public FormSplash()
        {
            InitializeComponent();
        }

        public static void ShowSplash()
        {
            if (_splashThread == null)
            {
                // show the form in a new thread
                _splashThread = new Thread((DoShowSplash)) {IsBackground = true};
                _splashThread.Start();
            }

        }

        public static void DoShowSplash()
        {
            if (_splashForm == null)
                _splashForm = new FormSplash();

            // create a new message pump on this thread (started from ShowSplash)
            Application.Run(_splashForm);

        }

        public static void CloseSplash()
        {
            // need to call on the thread that launched this splash
            if (_splashForm.InvokeRequired)
                _splashForm.Invoke(new MethodInvoker(CloseSplash));

            else
                Application.ExitThread();
        }

        private void lblLoading_Click(object sender, EventArgs e)
        {

        }

    }
}
